package it.osg.openstory.web;

import it.osg.openstory.model.User;
import it.osg.openstory.services.AuthenticationService;
import it.osg.openstory.util.Converter;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class RegistrationAction extends ActionSupport {

	private String name;
	private String mail;
	private String surName;
	private String userName;
	private String birthdate;
	private String password;
	
	private AuthenticationService loginService;
	@Override
	public String execute() throws Exception {
		User userToSave = new User();
		userToSave.setPassword(password);
		userToSave.setUserName(userName);
		userToSave.setBirthDate(Converter.convertDate(birthdate));
		userToSave.setMail(mail);
		userToSave.setSurName(surName);
		userToSave.setName(name);
		
		this.loginService.insertNewUser(userToSave);
		
		return SUCCESS;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurName() {
		return surName;
	}

	public void setSurName(String surName) {
		this.surName = surName;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getBirthdate() {
		return birthdate;
	}

	public void setBirthdate(String birthdate) {
		this.birthdate = birthdate;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public AuthenticationService getLoginService() {
		return loginService;
	}
	
	public void setLoginService(AuthenticationService loginService) {
		this.loginService = loginService;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}
	
}
